#include <iostream>
#include<cmath>
using namespace std;
string A;
int n;

int main() {
    cin >> A >> n;
    int size = A.size();
    int l = 0, r = 0;
    int  cnt = 0, mx = 0, li = 0;
    while (r < size)
    {
        while (r - l + 1 <= n)
        {
            if (A[r] == 'C' || A[r] == 'G')
            {
                cnt++;
                if (cnt > mx)
                {
                    mx = cnt;
                    li = l;
                }
            }
            r++;

        }
        if (A[l] == 'C' || A[l] == 'G')
            cnt--;
        l++;
    }
    for (int i = li; i < n + li; i++)
        cout << A[i];
}